package object;

public class Course {
    private int id;
    private String name;
    private String location;
    private String time;
    private Teacher teacher;

    public Course(int id, String name, String location, String time, Teacher teacher) {
        this.id = id;
        this.name = name;
        this.location = location;
        this.time = time;
        this.teacher = teacher;
    }

    public void setTeacher(Teacher teacher) {
        this.teacher = teacher;
    }

    public Teacher getTeacher() {
        return teacher;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getLocation() {
        return location;
    }

    public String getTime() {
        return time;
    }

    public String formatCourse() {
        return id + "," + name + "," + location + "," + time + "," + teacher.getName();
    }

    public static Course parseCourse(String line) {
        String[] parts = line.split(",");
        int id = Integer.parseInt(parts[0]);
        String name = parts[1];
        String location = parts[2];
        String time = parts[3];
        String teacherName = parts[4];
        Teacher teacher = new Teacher(id, teacherName, teacherName);
        return new Course(id, name, location, time, teacher);
    }
}
